﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml;
using System.Xml.Linq;

namespace DataScrubberExt
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string inputPath = textBox1.Text;
            string outputPath =textBox2.Text;
            string xpathsInFile = richTextBox1.Text;

            string[] xpaths = xpathsInFile.Split('\n');

            if (inputPath == "" || outputPath == "" || xpathsInFile == "") { 
                label4.Text = "Please enter correct values";
                return;
            }

            if(fetchFiles(inputPath, outputPath, xpaths))
                label4.Text = "Data Scrubbing Done successfully for all files.";
            else
                label4.Text = "Some problem occured while scrubbing.";

        }

        public static bool fetchFiles(string folderPath, string outputFolderPath, string[] xpaths)
        {
            int i = 1;
            try
            {
                new GenericScrubber(folderPath, outputFolderPath, xpaths).Scrubber();
                return true;
            }catch(Exception e)
            {
                return false;
                //throw e.Message;
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }
    }
}
